﻿@using Partner.Surround.Admin.Views
@{
    ViewBag.CurrentPageName = SurroundPageName.DailyTask;
}

<div class="layui-card">
    <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
        <i class="layui-icon layui-icon-add-1"></i>新增
    </button>

    <div class="layui-card-body">
        <table id="dailyTask-table" lay-filter="dailyTask-table"></table>
    </div>
</div>

<script type="text/html" id="dailyTaskCardItem">
    <div class="layui-col-md3 ew-datagrid-item">
        <div class="project-list-item" data-index="0" data-number="1">
            <div class="project-list-item-body">
                <h2>{{d.name}}</h2>
                <div class="project-list-item-text layui-text">{{d.remark}}</div>
                <div class="project-list-item-text layui-text">{{d.taskStateTypeName}}</div>
            </div>
        </div>
    </div>
</script>

@section scripts{
    <script type="text/javascript">
        layui.use(['abp', 'form','table', 'card'], function () {
            var $ = layui.$;
            var abp = layui.abp;
            var card = layui.card;
            var table = layui.table;

            card.render({
                elem: '#dailyTask-table',
                url: '@Url.Action("GetDailyTaskList", "DailyTask", new { area= "TaskCenter" })',
                template: '#dailyTaskCardItem',
                layout: ['count', 'prev', 'page', 'next'],
                parseData: function (res) {
                    return {
                        "code": res.result.code, //解析接口状态
                        "msg": res.result.msg, //解析提示文本
                        "count": res.result.count, //解析数据长度
                        "data": res.result.data //解析数据列表
                    };
                }
            });

            table.on('toolbar(dailyTask-table)', function (obj) {
                if (obj.event === 'add') {
                    window.add();
                }
            });

            window.add = function () {
				parent.layer.open({
                    type: 2,
                    title: "添加日常任务",
                    content: "@Url.Action("CreateOrUpdateDailyTask", "DailyTask", new { area= "TaskCenter" })",
                    area: ["710px","606px"],
                    shade: 0.1,
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        parent.window['layui-layer-iframe'+ index].submitForm();
                    }
                });
            }
        });
    </script>
}